Skip to content

Bugfix 13653 disabling a disease variant for a disease leads to error#13923

Merged
KarnaiahPesula merged 3 commits into
developmentfrom
bugfix-13653-disabling-a-disease-variant-for-a-disease-leads-to-error
May 7, 2026
Merged

Bugfix 13653 disabling a disease variant for a disease leads to error#13923
KarnaiahPesula merged 3 commits into
developmentfrom
bugfix-13653-disabling-a-disease-variant-for-a-disease-leads-to-error

Conversation

@KarnaiahPesula
Copy link
Copy Markdown
Contributor

@KarnaiahPesula KarnaiahPesula commented May 6, 2026

Fixes #

Summary by CodeRabbit

New Features

  • Added validation to prevent deletion of customizable enum values that are currently in use by active cases. When users attempt to remove such a value, the system displays a clear error message indicating that the value cannot be deleted due to existing case references, protecting data integrity.

Otherwise user will see the unwanted error message while opening the case/case management.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Warning

Rate limit exceeded

@KarnaiahPesula has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 43 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c9631510-38de-4deb-a96c-a9beccac052d

📥 Commits

Reviewing files that changed from the base of the PR and between d44c76c and 81acf7b.

📒 Files selected for processing (3)
  • sormas-api/src/main/resources/validations.properties
  • sormas-backend/src/main/java/de/symeda/sormas/backend/customizableenum/CustomizableEnumFacadeEjb.java
  • sormas-backend/src/main/java/de/symeda/sormas/backend/customizableenum/CustomizableEnumValueService.java
📝 Walkthrough

Walkthrough

This PR adds validation to prevent removal or deactivation of customizable enum values that are currently in use by cases. A new validation constant is introduced along with a query method to detect case usage, and a guard clause is added to the save method to enforce this constraint.

Changes

Prevent Removal of In-Use Customizable Enum Values

Layer / File(s) Summary
API Constants
sormas-api/src/main/java/de/symeda/sormas/api/i18n/Validations.java
New validation constant customizableEnumValueAlreadyInUse added to identify this validation failure.
Service Query
sormas-backend/src/main/java/de/symeda/sormas/backend/customizableenum/CustomizableEnumValueService.java
New public method areCasesUsingCustomizableEnumValue queries cases by disease and disease variant, returning a list of case UUIDs that use the value.
Validation Guard
sormas-backend/src/main/java/de/symeda/sormas/backend/customizableenum/CustomizableEnumFacadeEjb.java
In the save method, when an existing enum value is updated, any removed disease triggers a check; if cases use it, a ValidationRuntimeException is thrown with the validation key and affected case UUIDs.
Resource Message
sormas-api/src/main/resources/validations.properties
User-facing validation message for customizableEnumValueAlreadyInUse is added.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • obinna-h-n
  • raulbob

Poem

🐰 An enum value holds its ground,
No deletion till cases unbound,
With validation in place,
We prevent the disgrace,
Safe data all safely sound! 🔒

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description only contains the template boilerplate with no actual details filled in; the issue number is missing from 'Fixes #'. Fill in the issue number in the 'Fixes #' field to link this PR to the related issue, and optionally add a brief description of the changes made.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main bugfix being addressed: preventing errors when disabling a disease variant for a disease.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix-13653-disabling-a-disease-variant-for-a-disease-leads-to-error

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@sormas-api/src/main/resources/validations.properties`:
- Line 335: Update the message for the customizableEnumValueAlreadyInUse
property to improve clarity and consistency: replace "for %s case(IDs)" with
"used by case IDs: %s" and change the final clause to "before deleting or
deactivating" so the full message reads clearly that the customizable value is
used by specific case IDs and must be removed from them before deleting or
deactivating; locate and edit the customizableEnumValueAlreadyInUse entry in
validations.properties.

In
`@sormas-backend/src/main/java/de/symeda/sormas/backend/customizableenum/CustomizableEnumFacadeEjb.java`:
- Around line 173-184: The removal guard currently skips the "remove-all" case,
only inspects one removed disease via findAny(), and incorrectly uses
dto.getValue() instead of the persisted value; update the logic in
CustomizableEnumFacadeEjb to iterate all diseases in
existingEntity.getDiseases(), treat dto.getDiseases() being null/empty as “no
remaining diseases”, and for each disease not present in dto.getDiseases() call
service.areCasesUsingCustomizableEnumValue(disease,
getEnumValue(dto.getDataType(), disease, existingEntity.getValue())) (i.e., use
existingEntity.getValue() / persisted enum value) and if any returned uuids are
non-empty throw the same ValidationRuntimeException with the joined uuids;
replace the findAny() shortcut with a full check/early-exit on first conflict.

In
`@sormas-backend/src/main/java/de/symeda/sormas/backend/customizableenum/CustomizableEnumValueService.java`:
- Line 97: The integrity check in CustomizableEnumValueService uses
caseService.findBy(caseCriteria, false) which applies user/jurisdiction filters
and can miss cases; update the call to perform an unfiltered query (use the
findBy overload/flag that disables user filtering so the search ignores
jurisdiction/user constraints) so the integrity validation inspects all Case
records referenced by the enum value (change the second argument to the value
that turns off filtering or call the unfiltered findBy variant).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8145ceaf-04a2-4879-a69e-a3919b6d5ff2

📥 Commits

Reviewing files that changed from the base of the PR and between 5ba0cd0 and d44c76c.

📒 Files selected for processing (4)
  • sormas-api/src/main/java/de/symeda/sormas/api/i18n/Validations.java
  • sormas-api/src/main/resources/validations.properties
  • sormas-backend/src/main/java/de/symeda/sormas/backend/customizableenum/CustomizableEnumFacadeEjb.java
  • sormas-backend/src/main/java/de/symeda/sormas/backend/customizableenum/CustomizableEnumValueService.java

smsAuthSecretValueValidation = SMS Auth secret value is not valid
systemConfigurationValueValidationInvalidBackgroundColor = Pre-defined values are: green, red, indigo, gray, default (case-sensitive) otherwise must match hexadecimal format (with or without hash "#"), example: #dd2b0e or #4AA or dd2b0e
systemConfigurationValueValidationMenuSubtitle = Can be empty or up to 16 (any) characters. Can be used to define name of the environment: PRODUCTION - TEST etc.
customizableEnumValueAlreadyInUse = The customizable value %s is being used for %s case(IDs) and therefore cannot be deleted or deactivated. Please remove all references to this value before attempting to deactivate.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Improve the new validation text for clarity and consistency.

At Line 335, the phrase for %s case(IDs) is hard to read, and the final sentence only mentions deactivation even though the first sentence mentions deletion too. Consider clearer wording (e.g., “used by case IDs: %s” and “before deleting or deactivating”).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sormas-api/src/main/resources/validations.properties` at line 335, Update the
message for the customizableEnumValueAlreadyInUse property to improve clarity
and consistency: replace "for %s case(IDs)" with "used by case IDs: %s" and
change the final clause to "before deleting or deactivating" so the full message
reads clearly that the customizable value is used by specific case IDs and must
be removed from them before deleting or deactivating; locate and edit the
customizableEnumValueAlreadyInUse entry in validations.properties.

@KarnaiahPesula KarnaiahPesula requested a review from raulbob May 6, 2026 10:56
@KarnaiahPesula KarnaiahPesula merged commit 14a8b20 into development May 7, 2026
7 of 10 checks passed
@KarnaiahPesula KarnaiahPesula deleted the bugfix-13653-disabling-a-disease-variant-for-a-disease-leads-to-error branch May 7, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disabling a disease variant for a disease leads to error if value used - Customizable Enums - Case Directory

2 participants